<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作用域链练习</title>
    <script>

        var a ;
        function func(){
            console.log(a);
        }

        //调用方式二
        func();   //undefined
        //var a = 1;   相当于先声明a,然后a = 1;
        a = 1;

       // 调用方式一 :
        var a = 1;
        func();   //1

       var age = 18;
       var name = "Tom";
       function getAge(){
           var age = 19;
           var str = "hello";
           function getStr(){
               var str = "world";
               console.log(age);   //19
               console.log(name);  //Tom
               console.log(str);   //world
           }
           getStr();
       }
       getAge();
    </script>
</head>
<body>

</body>
</html>